<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--bootstrap插件-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link href="/static/plugin/bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/static/plugin/jo/joUI.css" rel="stylesheet"/>
    <!--字体插件-->
    <link href="/static/plugin/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="/static/plugin/layui-2.4.3/css/layui.css" rel="stylesheet"/>
    <!--ztree-->
    <link href="/static/plugin/zTree/css/metroStyle/metroStyle.css" rel="stylesheet"/>
    <!--common-->
    <link href="/static/css/common.css" rel="stylesheet"/>

    <!--配置信息-->
    <script src="/static/js/config.js"></script>
    <!--jquery-->
    <script src="/static/plugin/jquery/jquery-3.3.1.js"></script>
    <script src="/static/plugin/jquery/jquery.cookie.js"></script>
    <!--bootstrap-->
    <script src="/static/plugin/bootstrap/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <!--[if lt IE 9]>
    <script src="/static/plugin/other/html5shiv.js"></script>
    <script src="/static/plugin/other/respond.min.js"></script>
    <![endif]-->
    <!--layui-->
    <script src="/static/plugin/layui-2.4.3/layui.all.js"></script>
    <!--ztree-->
    <script src="/static/plugin/zTree/js/jquery.ztree.all.js"></script>
    <!--common-->
    <script src="/static/js/common.js"></script>
    <!--jo-->
    <script src="/static/plugin/jo/jo.js"></script>
    <script src="/static/plugin/jo/jo-adapt.js"></script>
    <script src="/static/plugin/jo/jo-page-view.js"></script>
    <script src="/static/plugin/jo/jo-page-form.js"></script>
    <script src="/static/plugin/jo/jo-listener.js"></script>
    <link href="/static/plugin/codemirror-5.29.0/lib/codemirror.css" rel="stylesheet"/>
    <link href="/static/plugin/codemirror-5.29.0/theme/seti.css" rel="stylesheet"/>
    <script src="/static/plugin/codemirror-5.29.0/lib/codemirror.js"></script>
    <script src="/static/plugin/codemirror-5.29.0/mode/xml/xml.js"></script>
    <script src="/static/plugin/codemirror-5.29.0/mode/css/css.js"></script>
    <script src="/static/plugin/codemirror-5.29.0/mode/javascript/javascript.js"></script>
    <script src="/static/plugin/codemirror-5.29.0/mode/htmlmixed.js"></script>
    <!--括号匹配-->
    <script src="/static/plugin/codemirror-5.29.0/addon/edit/matchbrackets.js"></script>
    <title>java代码</title>
    <style>
        .CodeMirror {
            border: 1px solid #eee;
            height: auto;
        }

        .CodeMirror-scroll {
            height: auto;
            overflow-y: hidden;
            overflow-x: auto;
        }
    </style>
</head>
<body>
<textarea id="code"></textarea>
<script type="text/javascript">
    $(function () {

    });
    var mixedMode = {
        name: "htmlmixed",
        scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
            mode: null},
            {matches: /(text|application)\/(x-)?vb(a|script)/i,
                mode: "vbscript"}]
    };
    var code = CodeMirror.fromTextArea(document.getElementById("code"), {
        mode: mixedMode,
        selectionPointer: true,
        theme:"seti",//主题
        matchBrackets:true,//括号匹配
        lineNumbers:true
    });
    var old = "";//编辑过后的旧值
    //设置内容
    function setContent(str){
        if(str){
            old = encodeURIComponent(str);//编码字符串
            console.info("收到传值:"+str);
            code.setValue(str);
        }else{
            code.setValue("");
        }

    }
    //获取内容
    function getContent(){
        var n = code.getValue();//取到html值
        if(old == encodeURIComponent(n)){
            return null;
        }
        return n;
    }
</script>
</body>
</html>
